home *** CD-ROM | disk | FTP | other *** search
- /* ZAP10.CPP */
- #include <graphics.h>
- #include <bios.h>
- #include <conio.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <math.h>
- #include <complex.h>
- void main (void)
- {
- char bd;
- int k, ko, maxrow, maxcol, r, rr, r1, r2, r3, zee;
- long numits, q;
- complex a[5], b[5];
- double qx, qy, qq, zx, zy, lx, ly, dx, dy, sx, sy, di;
- double x, y;
- complex z;
- int driver = VGA;
- int mode = 2;
- initgraph( &driver, &mode, "c:\\tc\\bgi\\");
- randomize();
- di = 32767.;
- numits = random(32700) + 100000;
- restart:
- zee = random(3) + 2;
- dx = 230.; dy = 180.; zx = 16.; zy = 12.;
- rr = random(6) + 9; /* color determination */
- golf:
- r = random(6) + 9;
- if (r == rr)
- goto golf;
- foxtrot:
- r1 = random(6) + 9;
- if (r1 == r || r1 == rr)
- goto foxtrot;
- hotel:
- r2 = random(6) + 9;
- if (r2 == r1 || r2 == r || r2 == rr)
- goto hotel;
- r3 = random(6) + 1;
- a[0] = complex(.65 - 1.3 * rand()/di, .65 - 1.3 * rand()/di);
- a[1] = complex(.65 - 1.3 * rand()/di, .65 - 1.3 * rand()/di);
- a[2] = complex(.65 - 1.3 * rand()/di, .65 - 1.3 * rand()/di);
- a[3] = complex(.65 - 1.3 * rand()/di, .65 - 1.3 * rand()/di);
- b[0] = complex(6.5 - 13. * rand()/di, 6.5 - 13. * rand()/di);
- b[1] = complex(6.5 - 13. * rand()/di, 6.5 - 13. * rand()/di);
- b[2] = complex(6.5 - 13. * rand()/di, 6.5 - 13. * rand()/di);
- b[3] = complex(6.5 - 13. * rand()/di, 6.5 - 13. * rand()/di);
- charlie:
- cleardevice();
- setcolor (1);
- rectangle(1, 1, maxcol-1, 450);
- moveto(1, 450);
- settextstyle(SANS_SERIF_FONT, HORIZ_DIR,1);
- setcolor (6);
- x = 0.; y = 0.; z = complex(x, y);
- outtext("ESC to Quit Space Bar for New Image Press 'P' to Fill Window");
- for (q = 1; q < numits; q++)
- {
- k = random(zee);
- z = a[k] * z + b[k]; /* fractal equation */
- x = real(z);
- y = imag(z);
- if (k == 0) /* color correction*/
- ko = r;
- if (k == 1)
- ko = rr;
- if (k == 2)
- ko = r1;
- if (k == 3)
- ko = r2; /* end color correction */
- if (k == 4)
- ko = r3;
- if (q > 10 )
- {
- putpixel (dx + zx * x, dy + zy * y, ko);
-
- if (x < sx) /* sizing constants */
- sx = x;
- if (x > lx)
- lx = x;
- if (y < sy)
- sy = y;
- if (y > ly)
- ly = y;
- }
- if (q == 10) /* baseline for sizing */
- {
- sx = x;
- lx = x;
- sy = y;
- ly = y;
- }
- if (kbhit() != 0) /* user break */
- break;
- if (abs(z) > 800.) /* "boundries' break */
- break;
- }
- skip:
- bd = getch();
- if (bd == 27)
- goto finis;
- if (bd == 32)
- goto restart;
- if (bd == 112)
- {
- zx = 610 / (lx - sx);
- zy = 425 / (ly - sy);
- dx = 320 - zx * (lx + sx) / 2;
- dy = 225 - zy * (ly + sy) / 2;
- goto charlie;
- }
- finis:
- if (bd != 27)
- goto skip;
- closegraph ();
- }
-
-